package jgrouse.jgdoc.ant;

import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.ObjectInputStream;
import java.io.OutputStreamWriter;
import java.util.Properties;

import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;

public class TemplateTask
{
	public static void main(String[] args) 
	{
		try
		{
			FileInputStream fis = new FileInputStream("api/jgrouse.jgd");
			
			ObjectInputStream os = null;
			Object o = null;
			try {
				os = new ObjectInputStream(fis);
				o = os.readObject();
			} finally {
				if (os != null) {
					os.close();
				}
			}
			Properties props = new Properties();
			props.put("velocimacro.library", "skins/common/vm/common.vm");
			Velocity.init(props);
			//props.put("velocimacro.library", "skins/common/vm/common.vm");
			VelocityContext context = new VelocityContext();
			context.put("jg", o);
			
			context.put("projectName", "jBooze");
			context.put("trueRootPath", "");
			
			context.put("rootPath", "");
			context.put("version", "0.55");
			context.put("objectName", "com.foo.bla.Object1");
			context.put("navSection", "logical");
			context.put("encoding", "UTF-8");
			
			
			Template template = null; 
			template = Velocity.getTemplate("skins/noframes/vm/test.vm");
				
	        BufferedWriter writer = new BufferedWriter(
	                    new OutputStreamWriter(System.out));
				
			template.merge( context, writer );
			writer.flush();
			
			
		} catch (Exception e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
